5. Solaris Installation and Programming of CodeWarrior®



This chapter explains the CodeWarrior Professional system requirements for operating on Sun Solaris, how to install the CodeWarrior software, and walks you through the creation of a console application. The topics in this chapter are:


Solaris System Requirements

The CodeWarrior IDE requires the following hardware and software:

Table 5.1 Solaris Requirements

Hardware
Sparc-based machine, at least 64 megabytes of RAM, CD-ROM drive
Software
Solaris version 2.5.1 or later, an X11-R5 server or later, a CDE window manager that is vX11-r5 or later, Motif 1.2 or later
Other
80 MB free hard disk space


Installing CodeWarrior on Solaris

The installation software on the CodeWarrior Professional Solaris CD-ROM installs all the necessary components you will need to use CodeWarrior. The installation software presents the options listed in Table 5.2.

Table 5.2 Installation types for Solaris

This option
Installs these items on your hard disk
CodeWarrior IDE & Java Support
all CodeWarrior development tools, compilers, linkers, libraries, and help files, as well as the Sun JDK version 1.1.6 and 1.2
GCC 2.8.1 Support
configures the IDE for GCC 2.8.1 (which must be previously installed)
CodeWarrior Documentation
documentation on functions and features the CodeWarrior IDE and using the IDE to write code for the Java VM on Solaris
CodeWarrior Examples
a set of example CodeWarrior projects and tutorials


Before You Install

Before installing the software on your computer, you should:

1. Read the CodeWarrior/Metrowerks Software License.

Make sure you understand and agree with the "Metrowerks Software License Agreement" before installing the software.

2. Make sure your software package is complete.

This software package should contain:

1. QuickStart Professional guide (optional on some products)

2. A CodeWarrior Professional Solaris Tools CD

3. A registration card

4. Geekware catalog


NOTE

If any of these items are missing, contact your local distributor or Metrowerks sales (sales@metrowerks.com). See "Metrowerks Support" for more information.

3. Make sure your computer system meets the specified hardware and software requirements.

See "Solaris System Requirements".


Solaris Installation Procedure

To install CodeWarrior Professional:

1. Launch the CodeWarrior installation program.

Insert the CodeWarrior Professional Solaris CD-ROM into your CD-ROM drive.

The installer program can be found in the following directory: /cdrom/cwpro_solaris/. Open a terminal window and run the installer like so:


  cd /cdrom/cwpro_solaris   ./install-sh

The installer will display a welcome message. Read it and press space to continue. However, you must first ensure you have "write" privileges.

The installer will check your environment to verify that it is compatible, and notify you if any incompatibilities are found. Type "y" (without the quotes) to continue once the check is complete.


TIP

You can type "q" (without the quotes) at most prompts during the setup process to stop the installation and exit the installation program.

2. Read the software license.

When the software license appears, please read it. If you agree, type "y" when you are asked if you accept the terms of the agreement.

3. Select destination for the files.

By default, the installer will set the install path to /usr/local. If you would like to install to another directory, type "n" to this prompt. Otherwise, type "y" to continue.

4. Choose components to install.

See "Installing CodeWarrior on Solaris" for a description of components that can be installed with this installer. The installer will ask you whether you want to install each one of these components. Type "y" to install a component, or "n" to skip it.


NOTE

If you choose to install GCC support, the installer will ask you to locate the GCC directory at this point.

5. Review your choices.

The installer will list the components you selected, and ask you if this is correct. Type "y" to continue, or "n" to make changes.

6. After installation, read the release notes.

After installation, please read the release notes for the latest release information. For information on CodeWarrior's Y2K compliance, please read the note on "CodeWarrior Year 2000 Compliance."

7. Install Adobe Acrobat.

To read CodeWarriors documentation, you must have Adobe Acrobat Reader installed on your system. Open the Documentation_Viewers directory in the cdrom directory and untar the acrdsrch_solaris_301.tar.gz file to install Acrobat Reader.


What's Installed

Once the installation software is finished, you will have a cwpro4 directory installed on your system. Inside will be all the components you chose during installation. See INSTALL.LOG for information on what has been installed.


Creating a Solaris Application

Follow these steps to create a simple console application.

1. Choose File `New Project.

The New Project dialog box appears.

2. Click the expansion control next to C_C++

The C_C++ group opens.

3. Click C to select the C stationery.

4. Click OK.

The File Save dialog box appears.


NOTE

Check the Create Folder box in the New Project window to create a new folder for your project in the selected location

5. Enter the project name.

Type in a project name and give it file extension .mcp (we used test.mcp). This enables the IDE to recognize the project file as a CodeWarrior project.

6. Use the standard navigation controls to specify and save the new project.

7. Click Save.

The File Save window closes and a new project based on the chosen stationery is created.

8. Choose File `New.

A new empty editor window opens.

9. Choose File `Save.

The File Save dialog box appears. Name the file HelloWorld.c and click Save. The .c extension enables the IDE to recognize this file as a source code file.

10. Enter the sample code:


  /* helloworld.c */   #include <stdio.h>
  int main(void){
   printf("Hello world, this is CodeWarrior!\n");
   return 0;
  }

NOTE

A hello.c file exists in the new project. Please ignore the existing file and proceed with the steps to create a new file with the example code.

11. Select the Sources group in the project window

The Sources group is highlighted.

12. With the editor window frontmost, choose Project`Add Window.

The HelloWorld.c file is added to the project window.

13. Select the file named "hello.c" in the project window

The hello.c file is highlighted.

14. Choose Project`Remove Selected Items.

The hello.c file is removed from the project window.

15. Choose Project`Build .

The project is compiled and the executable is built.

16. Run the executable. It is named "a.out", and is in the same folder as the project.

The executable runs and the console output appears (Figure 5.1).


NOTE

This must be run from a terminal window or the File Manager.

Figure 5.1 Console output for Solaris


Congratulations! You just created a program using the CodeWarrior IDE on Solaris. For information on programming resources, please refer to "CodeWarrior Documentation."





Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: support@metrowerks.com
Copyright © 1999, Metrowerks Corp. All rights reserved.

Last updated: May 25, 1999 * Chris Magnuson * John Roseborough